package homework;

import java.util.Stack;

public class HomeWork26 {
    public boolean IsPopOrder(int [] pushA,int [] popA) {
        Stack<Integer>stack=new Stack<>();
        int k=0;
        for (int i = 0; i < pushA.length; i++) {
            stack.add(pushA[i]);
            while(!stack.empty()&&stack.peek()==popA[k]){
                k++;
                stack. pop();
            }
        }
        if(!stack.empty()){
            return false;
        }else {
            return true;
        }
    }
}
